//
//  LeftView.m
//  edgeDemo
//
//  Created by dllo on 16/3/7.
//  Copyright © 2016年 徐宏飞. All rights reserved.
//

#import "LeftView.h"

#import "LeftTableViewCell.h"
#import "LeftHeaderView.h"

@interface LeftView ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *leftTableView;
@property (nonatomic, strong) NSMutableArray *listArray;

@end

@implementation LeftView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creareSubViews];
    }
    return self;
}

- (void)creareSubViews{

    self.leftTableView = ({
        UITableView *tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStyleGrouped];
        tableView.delegate = self;
        tableView.dataSource = self;
        
        tableView;
    });
    [self.leftTableView registerClass:[LeftTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self addSubview:self.leftTableView];
    
    [self getHeaderView];
    
    self.leftTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    
    
    
}

#pragma mark - 头视图
- (void)getHeaderView{
    
    LeftHeaderView *lhView = [[LeftHeaderView alloc] initWithFrame:CGRectMake(0, 0, 414, 250)];
    self.leftTableView.tableHeaderView = lhView;
    
}
#pragma mark -- 初始数据
-(NSMutableArray *)listArray{
    
    NSMutableArray *array = [NSMutableArray array];
    
    LeftCellModel *model0 = [LeftCellModel new];
    model0.tilte = @"车牌号:无";
    model0.icon_name = @"iconfont-guyizhedangchepaihao-2.png";
    model0.moreImageType = clickTypeAdd;
    [array addObject:model0];
    
    LeftCellModel *model1 = [LeftCellModel new];
    model1.tilte = @"我的钱包";
    model1.icon_name = @"iconfont-qianbao.png";
    model1.moreImageType = clickTypeMore;
    [array addObject:model1];
    
    LeftCellModel *model2 = [LeftCellModel new];
    model2.tilte = @"收藏停车场";
    model2.icon_name = @"iconfont-address.png";
    model2.moreImageType = clickTypeMore;
    [array addObject:model2];
    
    LeftCellModel *model3 = [LeftCellModel new];
    model3.tilte = @"消费记录0条";
    model3.icon_name = @"iconfont-qianbao.png";
    model3.moreImageType = clickTypeMore;
    [array addObject:model3];
    
    LeftCellModel *model4 = [LeftCellModel new];
    model4.tilte = @"违章信息";
    model4.icon_name = @"iconfont-xinxi.png";
    model4.moreImageType = clickTypeNone;
    [array addObject:model4];
    
    LeftCellModel *model5 = [LeftCellModel new];
    model5.tilte = @"分享";
    model5.icon_name = @"iconfont-fenxiang.png";
    model5.moreImageType = clickTypeNone;
    [array addObject:model5];
    
    LeftCellModel *model6 = [LeftCellModel new];
    model6.tilte = @"更多";
    model6.icon_name = @"iconfont-more-2.png";
    model6.moreImageType = clickTypeNone;
    [array addObject:model6];
    
    
    return array;
}


#pragma mark - 行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.listArray.count;
}



#pragma mark - cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    LeftTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.model = [self.listArray objectAtIndex:indexPath.row];
    return cell;
    
}


#pragma mark - 高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}


#pragma mark - 选中执行
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
}

@end

























